/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Threads;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;

/**
 *
 * @author QuangHau
 */
public class writeLbStatus extends Thread {

    JLabel lbstatus;
    String value;
    int len;
    boolean stopThread = false;

    public writeLbStatus(JLabel _lbstatus, String _value) {
        lbstatus = _lbstatus;
        value = _value;
        len = value.length() + 10;
        lbstatus.setText(value);
    }

    @Override
     public void run() {
        while (!stopThread) {
            if (lbstatus.getText().length() == len) {
                lbstatus.setText(value);
            } else {
                lbstatus.setText(lbstatus.getText() + ".");
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) {
                Logger.getLogger(writeLbStatus.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        lbstatus.setText("");
    }

    public void stopWrite() {
        stopThread = true;
    }
}
